class Pupil < ActiveRecord::Base

  set_table_name "aluno"

  belongs_to :person,:foreign_key => 'pessoa'
  belongs_to :curriculodado,:foreign_key => 'dadoscurriculo'
  belongs_to :ingresso,:foreign_key => 'ingresso'
  belongs_to :desligamento,:foreign_key => 'desligamento'

  has_many :historico

  validates_presence_of :id
  validates_presence_of :periodoingresso
  validates_presence_of :formaingresso
  validates_presence_of :periododesligamento
  validates_presence_of :formadesligamento
  validates_uniqueness_of :id

  def to_s
    self.pessoa.nome
  end

  def historicos
    Historico.find_all_by_aluno self.id
  end

end
